<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //promise 是来实现异步的
        //语法
        let promise = new Promise(function(resolve,reject){
            setTimeout(()=>{
                //如果异步异步成功
                // let message = '异步成功';
                // //成功后写数据
                // resolve(message)

                //如果异步失败
                let err = '异步失败';
                reject(err)
            },1000)

        })

        promise.then(function(value){
            //异步成功后执行的代码
            console.log(value);

        },function(reason){
            //异步失败后执行的代码
            console.log(reason);
        })

    </script>
</body>
</html>